//
//  TORadioDetailCell.m
//  B段项目
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "TORadioDetailCell.h"

@interface TORadioDetailCell ()

@property (nonatomic, strong)UIImageView *headImageView;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UIImageView *listenImageView;
@property (nonatomic, strong)UILabel *listenCountLabel;
@property (nonatomic, strong)UIImageView *playImageView;

@end

@implementation TORadioDetailCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubview];
    }
    
    return self;
}

-(void)createSubview
{
    self.headImageView = [[UIImageView alloc] init];
    self.headImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.headImageView];
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(20);
        make.centerY.mas_equalTo(self.contentView);
        make.width.height.mas_equalTo(HEIGHT/10);
        
    }];
    self.headImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.headImageView.clipsToBounds = YES;
    
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.headImageView.mas_right).offset(5);
        make.right.mas_equalTo(-100);
        make.top.mas_equalTo(self.headImageView);
        make.height.mas_equalTo(self.headImageView.mas_height).multipliedBy(0.35);
        
    }];
    
    
    
    self.listenImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.listenImageView];
    self.listenImageView.image = [UIImage imageNamed:@"iconfont-31shengbo.png"];
    [self.listenImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.headImageView.mas_right).offset(10);
        make.bottom.mas_equalTo(self.headImageView);
        make.height.width.mas_equalTo(self.headImageView).multipliedBy(0.2);
    }];
    
    
    
    self.listenCountLabel = [[UILabel alloc] init];
    self.listenCountLabel.backgroundColor = [UIColor clearColor];
    self.listenCountLabel.textColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
    self.listenCountLabel.font = [UIFont systemFontOfSize:11];
    [self.contentView addSubview:self.listenCountLabel];
    [self.listenCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.listenImageView.mas_right).offset(10);
        make.top.bottom.mas_equalTo(self.listenImageView);
        make.right.mas_equalTo(self.titleLabel.mas_right);
    }];
    
    
    
    
    
    self.playImageView = [[UIImageView alloc] init];
    self.playImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.playImageView];
    self.playImageView.image = [UIImage imageNamed:@"bofang.png"];
    
    [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(-20);
        make.centerY.mas_equalTo(self.headImageView);
        make.width.height.mas_equalTo(self.headImageView).multipliedBy(0.4);
    }];
}

-(void)setRadioModel:(TORadioModel *)radioModel
{
    _radioModel = radioModel;
    [self.headImageView sd_setImageWithURL:self.radioModel.coverimg placeholderImage:nil];
    self.titleLabel.text = self.radioModel.title;
    [self.titleLabel sizeToFit];
    self.listenCountLabel.text = self.radioModel.musicVisit;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
